<?php

namespace app\validate\adm;

use think\Validate;

class CarRepairValidate extends Validate
{
    /**
     * 定义验证规则
     * @var array
     */
    protected $rule = [
        'car_id' => 'require|integer|gt:0',
        'repair_date' => 'require|date',
        'repair_type' => 'require|in:1,2,3,4',
        'repair_content' => 'require|max:500',
        'repair_cost' => 'float|egt:0',
        'repair_shop' => 'max:100',
        'contact_person' => 'max:20',
        'contact_phone' => 'max:20',
        'remark' => 'max:500',
    ];

    /**
     * 定义错误信息
     * @var array
     */
    protected $message = [
        'car_id.require' => '车辆ID不能为空',
        'car_id.integer' => '车辆ID必须是整数',
        'car_id.gt' => '车辆ID必须大于0',
        'repair_date.require' => '维修日期不能为空',
        'repair_date.date' => '维修日期格式不正确',
        'repair_type.require' => '维修类型不能为空',
        'repair_type.in' => '维修类型值不正确',
        'repair_content.require' => '维修内容不能为空',
        'repair_content.max' => '维修内容不能超过500个字符',
        'repair_cost.float' => '维修费用必须是数字',
        'repair_cost.egt' => '维修费用不能为负数',
        'repair_shop.max' => '维修店名称不能超过100个字符',
        'contact_person.max' => '联系人不能超过20个字符',
        'contact_phone.max' => '联系电话不能超过20个字符',
        'remark.max' => '备注不能超过500个字符',
    ];

    /**
     * 定义验证场景
     * @var array
     */
    protected $scene = [
        'add' => ['car_id', 'repair_date', 'repair_type', 'repair_content', 'repair_cost', 'repair_shop', 'contact_person', 'contact_phone', 'remark'],
        'edit' => ['id', 'car_id', 'repair_date', 'repair_type', 'repair_content', 'repair_cost', 'repair_shop', 'contact_person', 'contact_phone', 'remark'],
    ];
}